# !usr/bin/env python
# -*- coding:utf-8 _*-
"""
@Author:张广勤
@Web site: https://www.tunan.wang
@Github:www.github.com
 
@File:everydayxinzen1_0.py
@Time:2024/12/23 20:14

@Motto:不积跬步无以至千里，不积小流无以成江海！
"""

from cctv_news.date_list1_0 import generate_date_list
from cctv_news.getlastdate1_0 import get_latest_date
from cctv_news.newdate1_0 import find_latest_date
from datetime import datetime, timedelta

# date_list = generate_date_list(get_latest_date("news_md")+timedelta(days=1),find_latest_date("../news/outputnews_2024.csv"))
# print(date_list)

# 假设get_latest_date返回的是YYYYMMDD格式的字符串
latest_date_str = get_latest_date("news_md")
# 将字符串转换为datetime对象
latest_date = datetime.strptime(latest_date_str, '%Y%m%d')

# 计算下一天的日期
next_day = latest_date + timedelta(days=1)

# 将计算出的日期转换回字符串，以便find_latest_date函数可以处理
next_day_str = next_day.strftime('%Y%m%d')

# 假设find_latest_date函数接受的是字符串格式的日期
latest_date_from_csv = find_latest_date("../news/outputnews_2024.csv")
eve_day = datetime.strptime(latest_date_from_csv, "%Y%m%d")
the_day_before = eve_day + timedelta(days=-1)
the_day_before_str = the_day_before.strftime('%Y%m%d')
# 生成日期列表
date_list = generate_date_list(next_day_str, the_day_before_str)

print(date_list)